package cn.yj.common;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * @author 永健
 * @since 2022-02-18 17:03
 */
public class PayAutoConfigurationConditional implements Condition {
    private static final boolean START_PAY = false;
    private static final String PAY_START_KEY = "pay.start";
    @Override
    public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
        Environment environment = conditionContext.getEnvironment();
        return Boolean.valueOf(environment.getProperty(PAY_START_KEY, String.valueOf(START_PAY)));
    }
}
